import config from '@src/core/config'

export function loadBlobTextures (self) {
  const blobTextures = [];

  for (var i = 0; i < 16; i++) {
    const url = config.getImageUrl(i)
    const texture = new THREE.ImageUtils.loadTexture(url, undefined, function() {

      self.loadingPercentageMax += 2;
    }, function() {

      self.loadingPercentageMax += 2;
    });

    texture.premultiplyAlpha = true;

    blobTextures.push(texture);
  }

  return blobTextures
}

export function createGeographies () {
  // const category = ['Event', 'Meeting', 'Military', 'Character']
  const category = ['大事件', '重要会议', '军事活动', '重要人物']
  const geographies = {
    category,
    // categoryCh,
    geoLane: {},
    colors: [ 0xFFBA0A, 0xF14F11, 0x8DC73C, 0x0071BC, 0x9E005D ],
  };

  category.forEach((e,i) => { geographies.geoLane[e] = i; });

  return geographies
}

export function fetchObject (callback) {
  fetch(config.landscapeCoords)
    .then(res => res.json())
    .then(callback, () => console.log('Failed to load terrain geometry.'));
}
